package com.wsc.entity;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "t_students")
@AllArgsConstructor
@NoArgsConstructor
@Data
//@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
public class Student {
	@Id
	// 主键生成机制 自增
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;// 编号
	//@Column(unique=true)指这个字段的值在这张表里不能重复，所有记录值都要唯一，就像主键那样;
	@Column(unique=true)
	private String cardno;// 卡号
	private String name;// 姓名
	private String sex;// 性别
	private Integer membershipid;// 身份编号
	private Integer status;// 状态 0：正常 >0 当前所在的阅览室编号
	private String reark;// 备注
	private String stuno;
	// id cardid name sex membershipid status reark stuno
	// 多对一 关联表 立即加载
	@ManyToOne(targetEntity = Membership.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	// 外键列 关联表的主键列 
	@JoinColumn(name = "membershipid", referencedColumnName = "id",insertable = false, updatable = false)
	private Membership membership;

}
